param ([string[]] $ItemFQNs, [string[]] $ConnectorFQNs)

function Remove-EMIItem([string] $ItemFQN)
{
    $ItemToRemove = [DataWorks.MI.Core.Item]::GetInstance($ItemFQN)
    If ($ItemToRemove -ne $Null)
    {
        $ItemToRemove.Delete()
    }
}

function Remove-EMIConnector([string] $ItemFQN)
{
    $ConnectorToRemove = [DataWorks.MI.Core.Item]::GetInstance($ItemFQN)
    If ($ConnectorToRemove -ne $Null)
    {
        $ConnectorToRemove.Invoke("Delete")
    }
}

function Delete-EMIItems()
{
    if (($ItemFQNs -ne $Null) -and ($ItemFQNs.Count -gt 0))
    {
        $ItemFQNs | Foreach-Object { Remove-EMIItem -ItemFQN $_ }
    }
    
    if (($ConnectorFQNs -ne $Null) -and $ConnectorFQNs.Count -gt 0)
    {
        $ConnectorFQNs | Foreach-Object { Remove-EMIConnector -ItemFQN $_ }
    }
}

Delete-EMIItems
















